<meta charset="utf-8"/>
<div class="row">
  <div class="col-xs-12">
    <div class="row">
      <div class="col-xs-12">
        <div style="height:36px;margin-top:2px">
          <table class="no-border" style="display:inline">
            <tr>
              <td permission='activity_btn_listData' style="padding-right:6px;display:none">
                名称
              </td>
              <td permission='activity_btn_listData' style="display:none">
                <input type="text" id="key_title" class="form-control search-query" placeholder="输入活动促销名称" style="width:160px"/>
              </td>
              <td permission='activity_btn_listData' style="padding:0 6px;display:none" class="hidden-480">
                开始日期
              </td>
              <td permission='activity_btn_listData' style="display:none" class="hidden-480">
                <input type="text" id="key_start_date" class="form-control search-query" placeholder="输入开始日期" style="width:144px"/>
              </td>
              <td permission='activity_btn_listData' style="padding:0 6px;display:none" class="hidden-480">
                结束日期
              </td>
              <td permission='activity_btn_listData' style="display:none" class="hidden-480">
                <input type="text" id="key_end_date" class="form-control search-query" placeholder="输入结束日期" style="width:144px"/>
              </td>
              <td permission='activity_btn_listData' style="display:none">
                <div class="input-group">
                  <span class="input-group-btn"><button type="button" class="btn btn-inverse btn-white" id="btnSearch" title="搜索查询"><span class="ace-icon fa fa-search bigger-110"></span>搜索</button></span>
                </div>
              </td>
              <td permission='activity_btn_add' style="display:none">
                <div class="input-group">
                  <span class="input-group-btn"><button type="button" class="btn btn-inverse btn-white" id="btnAdd" title="新增|添加"><span class="ace-icon fa fa-plus bigger-110"></span>添加</button></span>
                </div>
              </td>
            </tr>
          </table>
          <div class="hidden-480 pull-right tableTools-container" permission='activity_btn_listData' style="display:none;margin-bottom:2px"></div>
        </div>
        <table id="tableListGoodsPromotion" class="table table-striped table-bordered table-hover">
          <tbody>
          <tr>
            <td style="text-align:center;height:37px">正在加载……</td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
<div id="div_goods_promotion_edit" style="display:none;padding-top:2px">
  <form class="form-horizontal" id="form_goods_promotion_edit" role="form">
    <label class="col-sm-3 control-label no-padding-right"><div class="hr-4">活动名称<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-7">
      <div class="hr-4"></div>
      <input type="text" id="title" placeholder="活动促销名称" class="form-control" maxlength="128" title="活动促销名称"/>
    </div>
    <label class="col-sm-3 control-label no-padding-right"><div class="hr-4">开始日期<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-7">
      <div class="hr-4"></div>
      <input type="text" id="start_date" placeholder="开始日期" class="form-control" maxlength="19" title="开始日期"/>
    </div>
    <label class="col-sm-3 control-label no-padding-right"><div class="hr-4">结束日期<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-7">
      <div class="hr-4"></div>
      <input type="text" id="end_date" placeholder="结束日期" class="form-control" maxlength="19" title="结束日期"/>
    </div>
    <label class="col-sm-3 control-label no-padding-right"><div class="hr-4">参与商品<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-7" style="padding-left:0px">
      <div class="hr-4"></div>
      <div class="div_container_checkbox"></div>
    </div>
    <label class="col-sm-3 control-label no-padding-right"><div class="hr-4">活动介绍<span style="color:#f00;display:inline-block;vertical-align:middle;width:auto;height:14px;line-height:18px">*</span></div></label>
    <div class="col-sm-7" style="margin-bottom:6px">
      <div class="hr-4"></div>
      <textarea type="text" id="introduce" placeholder="活动介绍" class="form-control limited" maxlength="921600000" style="width:100%;height:550px;" title="请输入活动介绍"></textarea>
    </div>
  </form>
</div>
<div id="divKeyColumns" style="display:none;padding:1px 0px;"></div>
<div style="display:none;">
  <input type="hidden" id="activity_btn_listData"/>
  <input type="hidden" id="activity_btn_add"/>
  <input type="hidden" id="activity_row_edit"/>
  <input type="hidden" id="activity_row_queryById"/>
  <input type="hidden" id="activity_row_delById"/>
</div>
<div id="div_view_integral" style="display:none;padding-top:6px;padding-left:16px"></div>
<script type="text/javascript">
  ;(function($){
    var tableDom = '#tableListGoodsPromotion';
    var urlRoute = '/goodsPromotion/';/*请求controller层的url*/
    var getList = urlRoute + 'listData';/*获取数据列表*/
    var urlAdd = urlRoute + 'add';/*添加*/
    var urlEdit = urlRoute + 'edit';/*编辑*/
    var urlQueryById = urlRoute + 'queryById';/*根据id查询对应的数据*/
    var urlQueryGoods = urlRoute + 'queryGoods';/*获取全部商品*/
    var urlDelById = urlRoute + 'delById';/*根据id删除对应的数据*/
    var thisTable = null;
    var listDatas = null;//新增或编辑时所需的数据
    var editListData = [];//编辑去查询返回的商品id集合json数组
    var listIntegralLevel = [
      {
        text : '省分公司佣金',
        id : 'level_value1',
        level : 1
      },
      {
        text : '市分公司佣金',
        id : 'level_value2',
        level : 2
      },
      {
        text : '区级代理利润',
        id : 'level_value3',
        level : 3
      },
      {
        text : '直营门店利润',
        id : 'level_value4',
        level : 4
      },
      {
        text : '推荐人的积分',
        id : 'level_value5',
        level : 5
      }
    ];
    var scoresJson = null;//判断此是否有值来确定是否是新增或编辑
    thisPage = {
      init : function(){
        this.initTable();
        this.createDropdown();
        this.initDom();
        this.addEvent();
      },
      initDom : function(){
        laydate.render({
          elem: '#key_start_date',//指定元素
          format : 'yyyy-MM-dd HH:mm:ss',/*格式*/
          showBottom : true,/*是否显示底部栏*/
          type: 'datetime'/*格式,datetime|date|time*/
        });
        laydate.render({
          elem: '#key_end_date',//指定元素
          format : 'yyyy-MM-dd HH:mm:ss',/*格式*/
          showBottom : true,/*是否显示底部栏*/
          type: 'datetime'/*格式,datetime|date|time*/
        });
        laydate.render({
          elem: '#start_date',//指定元素
          format : 'yyyy-MM-dd HH:mm:ss',/*格式*/
          showBottom : true,/*是否显示底部栏*/
          type: 'datetime'/*格式,datetime|date|time*/
        });
        laydate.render({
          elem: '#end_date',//指定元素
          format : 'yyyy-MM-dd HH:mm:ss',/*格式*/
          showBottom : true,/*是否显示底部栏*/
          type: 'datetime'/*格式,datetime|date|time*/
        });
      },
      divDisplay : function(kid,objs){
        //var checked = $(objs).prev()[0].checked;//取值
        //$('#div_row_'+kid).css('display',checked ? 'none' : '');//显示或隐藏,不带动画
        $('#div_row_'+kid).slideToggle('slow');//动画,自动识别并切换是否显示或隐藏
      },
      //需要或为空时才去请求,减轻服务器压力,避免每次加载时就请求获取数据
      getGoods : function(callback){
        if(listDatas == null){
          layerFn.queryGetHintResult(urlQueryGoods,{},function(data){
            if(AppKey.code.code200 == data.code){
              listDatas = data.data;
              callback(listDatas);
            }else{
              callback();//注意判断为空的处理,因为此处不可能有空,所以不需要判断
            }
          });
        }else{
          callback(listDatas);
        }
      },
      createDropdown: function(){},
      addEvent: function(){
        $(tableDom +' tbody').on('dblclick','td:not(:first-child,:last-child)',function(){//除去每行的第一个和最后一个单元格均可双击事件
          if(verifyFn.inputRequired('#activity_row_edit')){
            return;
          }
          thisPage.trDblclick(thisTable.row($(this).parent()).data());
        });
        $('#btnAdd').on('click', function(){
          thisPage.edit();
        });
        //搜索按钮
        $('#btnSearch').on('click', function(){
          thisPage.search();
        });
        //重置按钮
        //按钮组-自定义显示列
        $('#iconColumn').parent().parent().on('click', function(){
          pageDataTable.columnCustom(thisTable, tableDom,'#divKeyColumns');
        });
        //按钮组-搜索
        $('#iconRefresh').parent().parent().on('click', function(){
          thisPage.search();
        });
      },
      //处理是否是新增还是编辑,第一个参数是全部酒商品;第2个参数是修改的酒商品;第3个参数等级;第4个参数等级对应的积分数
      IntegralHandler : function(goodsListValue,list){
        var container_checkbox = $('.div_container_checkbox');
        container_checkbox.empty();//置空
        var html = '';
        for(var e=0;e<goodsListValue.length;e++){
          var obj = goodsListValue[e];
          var goods_key = obj.kid;//无需借助uuid,因为商品信息是从后端拿到
          html += '<div id="div_dom_'+goods_key+'"><input style="display:none" type="checkbox" name="goods" id="'+goods_key+'"/>';//此处的div用于换行-开始,input的id用于判断是否已勾选
          html += '<label class="checkbox" style="margin:0px;padding-top:0px;min-height:0px" onclick="thisPage.divDisplay(\''+goods_key+'\',this);" id="label_'+goods_key+'">'+obj.contract_name+'（原价：'+obj.price+'）</label>';//label的id用于勾选或取消选中
          html += '<div id="div_row_'+goods_key+'" style="display:none">';//包裹div开始,用于控制是否显示的
          html += '<div><label>本次活动价格</label><input type="text" id="price_'+goods_key+'" style="height:34px;line-height:34px;margin-left:6px" maxlength="15" oninput="value=value.replace(/[^\\d.]/g,\'\')" placeholder="设置活动价格" title="设置活动价格"/></div>';
          for(var j=0;j<listIntegralLevel.length;j++){
            var objs = listIntegralLevel[j];
            if(j == 3){//仅显示'直营门店利润'
              html += '<div style="margin-top:2px"><label>'+objs.text+'</label><input type="text" id="level_value_'+(j+1)+goods_key+'" value="0.00" style="height:34px;line-height:34px;margin-left:6px" maxlength="15" oninput="value=value.replace(/[^\\d.]/g,\'\')" title="设置'+objs.text+'" placeholder="设置'+objs.text+'"/></div>';//商品的等级对应的积分数
            }
          }
          html += '</div>';//包裹div结束
          html += '</div>';//此处的div用于换行-结束
        }
        container_checkbox.html(html);//填充
        container_checkbox.hcheckbox();//初始化样式
        //编辑时回写各项数据
        if(list != null){
          for(let g = 0; g < list.length; g++){
            var listObj = list[g];
            var goodsId = listObj.goods_id;
            $('#price_'+goodsId).val(listObj.price);//回写活动价格
            var levelValues = listObj.level_values.split(',');
            var levelScores = listObj.scores.split(',');
            for(let d = 0; d < levelValues.length; d++){
              $('#level_value_'+levelValues[d]+goodsId).val(levelScores[d]);//回写不同等级的积分数
            }
            //处理显示
            $('#div_row_'+goodsId).css('display','');
            $('#label_'+goodsId).addClass("checked").prev()[0].checked = true;//选中,赋值
          }
        }        
      },
      /**获取已选中的主键集合,用法:var kids = thisPage.getKeyIds();if(kids == null){layerFn.alert('请选择要操作的数据', AppKey.code.code199);return;}*/
      getKeyIds : function(){
        var arrays = thisTable.rows({selected : true}).data();//获取已勾选的数据行
        if(arrays.length == 0){
          return null;
        }
        var kids = '';
        for(var i = 0; i < arrays.length; i++){
          var value = arrays[i].kid;
          if(value != ''){
            if(kids.length > 0) kids += ",";
            kids += value;
          }
        }
        return kids;
      },
      initTable : function(){
        var optsVisible = getOptsVisible('activity_row');//确定是否要显示操作选项,若是多个按钮权限时以逗号,隔开
        var aoColumns = [];
        aoColumns.push({
          data : "title",
          sortable : false,
          title : "活动促销名称"
        });
        aoColumns.push({
          data : "deleted",
          sortable : false,
          title : "是否下架",
          width: "121px",
          render : function(value){
            switch (value){
              case 0:
                return '正常';
              case 1:
                return '下架';
              default:
                return '';
            }
          }
        });
        aoColumns.push({
          data : "start_date",
          sortable : false,
          title : "开始日期",
          width: "121px",
          render : function(value){
            if(value){
              return winFn.formatDate(value,true);
            }else{
              return "";
            }
          }
        });
        aoColumns.push({
          data : "end_date",
          sortable : false,
          title : "结束日期",
          width: "121px",
          render : function(value){
            if(value){
              return winFn.formatDate(value,true);
            }else{
              return "";
            }
          }
        });
        aoColumns.push({
          data : "add_date",
          sortable : false,
          title : "发布时间",
          width: "121px",
          render : function(value){
            if(value){
              return winFn.formatDate(value,true);
            }else{
              return "";
            }
          }
        });
        aoColumns.push({
          data : "introduce",
          sortable : false,
          title : "活动介绍",
          width: "160px",
          render : function(value,type,row,meta){
            return "<a href='javascript:thisPage.viewIntroduce("+ meta.row +");' style='text-decoration:none;outline:none;'>查看详情</a>";
          }
        });
        aoColumns.push({
          data : "kidOps",
          sortable : false,
          title : "详情选项",
          width: "160px",
          render : function(value,type,row,meta){
            return "<a href='javascript:thisPage.viewIntegral("+ meta.row +");' style='text-decoration:none;outline:none;margin-right:8px'>商品详情</a>";
          }
        });
        if(optsVisible){
          aoColumns.push({
            data : "_kid_",
            width : "75px",
            title : "<label style='color:#000;margin-left:6px;' title='单行操作'>操作选项</label>",/*此处的字‘操作选项’请勿修改,此处的文字还有其它用途*/
            sortable : false
          });
        }
        var columnDefs = [];
        if(optsVisible){//是否来显示某列
          columnDefs.push({
            targets : -1,
            render : function(value,type,row,meta){
              return "<a title='编辑|修改' href='javascript:thisPage.rowEdit("+ meta.row +");' style='outline:none;text-decoration: none;color:#3b8cff;margin-left:4px;display:none' permission='activity_row_edit'>编辑</a><a title='删除当前行数据' class='hidden-480' href='javascript:thisPage.rowDel("+ meta.row +");' style='outline:none;text-decoration: none;color:#f00;margin-left:6px;display:none' permission='activity_row_delById'>删除</a>";
            }
          });
        }
        columnDefs.push({
          targets : [0],
          render : function(value,type,row,meta){
            return pageDataTable.formatColumn(value);
          }
        });
        columnDefs.push({
          visible : false,//列的隐藏显示
          targets : []//指定列索引
        });
        thisTable = pageDataTable.initDataTable({
          tableDom : tableDom,
          sAjaxSource : getList,
          fnServerParams : function(params){
            params.push(
              {"name":"title","value":winFn.getDomValue('#key_title')},
              {"name":"date_start","value":winFn.getDomValue('#key_start_date') ? new Date(winFn.getDomValue('#key_start_date').replace(new RegExp("-","gm"),"/")).getTime()/1000 : ''},
              {"name":"date_end","value":winFn.getDomValue('#key_end_date') ? new Date(winFn.getDomValue('#key_end_date').replace(new RegExp("-","gm"),"/")).getTime()/1000 : ''}
            );
          },
          aoColumns : aoColumns,
          columnDefs : columnDefs,
          complete : function(settings,data){},
          selected : function(selected){}
        });
        pageDataTable.buttons(thisTable);
        pageDataTable.action(thisTable);
        pageDataTable.select(thisTable, tableDom);
        pageDataTable.tooltip();
        $('.dataTables_scroll .dataTables_scrollBody').removeAttr('style');//解决dataTable表头下拉框被tbody遮挡
      },
      viewIntegral : function(rowIndex){
        function getLevelText(level){
          for(var f=0;f<listIntegralLevel.length;f++){
            var obj = listIntegralLevel[f];
            if(obj.level == level){
              return obj.text;
            }
          }
        }
        var row = thisTable.row(rowIndex).data();
        layerFn.queryGetHint(urlQueryById,{target:row.kid},function(data){
          var list_goods = data.data;
          var html = '';
          for(var e=0;e<list_goods.length;e++){
            var obj = list_goods[e];
            html += '<div>';
              html += '<div>';
                html += '<label title="活动商品">'+obj.contract_name+'，活动价格：'+obj.price+'</label>';
              html += '</div>';
              var arrLevels = obj.level_values.split(',');
              var arrScores = obj.scores.split(',');
              for(var y=0;y<arrLevels.length;y++){
                html += '<div>';
                  html += '<label>'+getLevelText(arrLevels[y])+'：'+arrScores[y]+'</label>';
                html += '</div>';
              }
            html += '</div>';
          }
          $('#div_view_integral').html(html);
          layerFn.viewDialog('查看活动商品、价格、积分数详情','#div_view_integral',['450px','500px']);
        });
      },
      viewIntroduce : function(rowIndex){
        var row = thisTable.row(rowIndex).data();
        layerFn.viewValue(row.introduce,"430px");
      },
      //双击事件
      trDblclick: function(data){
        if(data){
          thisPage.edit(data.kid);
        }
      },
      search: function(){
        if(verifyFn.inputCheck('#activity_btn_listData','没有操作权限')) return;
        $(tableDom + '_wrapper table input[type=checkbox]').prop('checked',false);
        thisTable.draw();
      },
      resetForm: function(){
        winFn.clearFormData('#form_goods_promotion_edit');
      },
      edit: function(kid){
        editListData = [];//置空
        thisPage.getGoods(function(list){
          $('#scoreName').attr('title',"设置分成积分数");
          var title = '添加';
          if(kid != null && kid.length > 0){
            if(verifyFn.inputCheck('#activity_row_queryById','没有操作权限')) return;
            title = '编辑';
            layerFn.queryByIdHint(urlQueryById, kid, function(data){
              editListData = data.data.list;//赋值
              thisPage.openDialog(title,list,kid,data);
            });
          }else{
            scoresJson = null;//新增
            thisPage.openDialog(title,list);
          }
        });
      },
      openDialog : function(title,list,kid,map){
        var url = urlAdd;
        if(kid != null && kid.length > 0){
          url = urlEdit;
          if(verifyFn.inputNull('#activity_row_edit','没有编辑权限')) return;
        }else{
          if(verifyFn.inputNull('#activity_btn_add','没有添加权限')) return;
        }
        //获取商品的名称
        function getGoodsName(keyId){
          for(var k=0;k<listGoods.length;k++){
            var goodsObj = listGoods[k];
            if(keyId == goodsObj.kid){
              return goodsObj.contract_name;
            }
          }
        }
        layerFn.winKindEditor(title,'#div_goods_promotion_edit',['#introduce'],(map == null ? null : map.data.info), ['966px','600px'], function(layerIndex, layero){
          if(verifyFn.inputEmpty('#title')) return;
          if(verifyFn.inputEmpty('#start_date')) return;
          if(verifyFn.inputEmpty('#end_date')) return;
          var divDoms = $("label[id^='label_']");//获取以label_开头的id,以便于是否已勾选的商品
          var checkeds = [];
          for(var s=0;s<divDoms.length;s++){
            var dom_div = divDoms[s];
            var label_dom = $(dom_div).attr('id');
            var isChecked = $('#'+label_dom).prev()[0].checked;//取值,判断是否已勾选
            if(isChecked){
              checkeds.push(label_dom.substring(6,label_dom.length));
            }
          }
          if(checkeds.length == 0){
            layerFn.alert('选择参与活动的商品',AppKey.code.code199);
            return;//跳出循环
          }
          var jsonValues = [];//存储商品id、商品的活动价格、不同等级对应的积分数
          var jsonSelected = {};//存储提交前已勾选的商品id的json对象
          for(let u = 0; u < checkeds.length; u++){
            var json = {};
            var selectedGoodsId = checkeds[u];//获取商品的id
            var price = winFn.getDomValue('#price_'+selectedGoodsId);//商品活动的价格
            if(price == null){
              layerFn.alert('请输入['+getGoodsName(selectedGoodsId)+']的活动价格',AppKey.code.code199);
              return;
            }
            json['price'] = price;
            json['goods_id'] = selectedGoodsId;
            jsonSelected[''+selectedGoodsId+''] = selectedGoodsId;//存储已勾选的商品
            var arrLevel = [];
            for(let a = 0; a < listIntegralLevel.length; a++){
              var _ll = listIntegralLevel[a].level;//等级的值
              var levelValue = $('#level_value_'+_ll+selectedGoodsId).val();//等级积分数的值
              var jsonScore = {};
              jsonScore['level_value'] = _ll;//等级
              jsonScore['score'] = levelValue;//等级积分数
              arrLevel.push(jsonScore);
            }
            json['level_score'] = arrLevel;
            jsonValues.push(json);
          }
          if(verifyFn.inputNull('#introduce','活动介绍不能为空')) return;
          var jsonData = {};//编辑查询返回的商品json对象
          for(var o=0;o<editListData.length;o++){
            var gd = editListData[o].goods_id;
            jsonData[''+gd+''] = gd;//存储已勾选的商品json对象
          }
          var dels = [];//从查询返回的集合里仅勾选提交的商品id集合
          if(editListData.length > 0){
            for(var so in jsonData){
              if(jsonData[so] == jsonSelected[so]){
                dels.push(jsonData[so]);
              }
            }
          }
          for(var c=0;c<dels.length;c++){
            delete jsonData[dels[c]];//从返回的json数组里删除编辑提交前未勾选的商品id
          }
          var delIds = '';
          for(jda in jsonData){
            if(delIds.length > 0){
              delIds += ','+jda;
            }else{
              delIds += jda;
            }
          }
          var params = {
            title : winFn.getDomValue('#title',true),
            introduce : winFn.getDomValue('#introduce',true),
            score : JSON.stringify(jsonValues),//含商品id、商品的活动价格、不同等级对应的积分数
            delIds : delIds,//后端删除`未勾选的商品id`
            start_date : new Date(winFn.getDomValue('#start_date').replace(new RegExp("-","gm"),"/")).getTime()/1000,
            end_date : new Date(winFn.getDomValue('#end_date').replace(new RegExp("-","gm"),"/")).getTime()/1000,
            kid : kid
          };
          layerFn.submit(url,params,function(data){
            thisPage.complete(data,layerIndex,true);
          });
        });
        thisPage.resetForm();
        if(map != null){
          $.each(map.data.info,function(k,v){
            try{
              if('start_date' == k){
                $('#' + k).val(winFn.formatDate(v,true));
                return true;
              }
              if('end_date' == k){
                $('#' + k).val(winFn.formatDate(v,true));
                return true;
              }
              $('#' + k).val(v);
            }catch(e){}
          });
        }
        if(map != null){
          thisPage.IntegralHandler(list,map.data.list);
        }else{
          thisPage.IntegralHandler(list);//必须放在最后处理是否是新增时清空还是编辑时赋值
        }
      },
      rowEdit : function(rowIndex){
        var row = thisTable.row(rowIndex).data();
        thisPage.edit(row.kid);
      },
      rowDel : function(rowIndex){
        if(verifyFn.inputCheck('#activity_row_delById','没有删除操作权限')) return;
        var row = thisTable.row(rowIndex).data();
        layerFn.confirm('删除后无法恢复,确定要删除吗?', function(){
          layerFn.delByIdHint(urlDelById, row.kid,function(data){
            thisPage.complete(data,null,true);
          });
        });
      },
      //查看隐藏部分是全部内容,用法 render : function(value,type,row,meta){return thisPage.rowColumnView(value);}
      rowColumnView : function(value){
        if(value == null || value == undefined || value == '') return '';
        value = typeof value === 'string' ? value.replace(/</g, '&lt;').replace(/"/g, '&quot;') : value;//final
        var len = value.length;
        if(len > 30){
          return "<a href='javascript:layerFn.viewValue(\""+value+"\",\"430px\");' title='点击查看详情' style='outline:none;text-decoration: none;'>"+value.substring(0,30)+"…</a>";
        }else{
          return value;
        }
      },
      complete: function(data,index,search){
        try{
          if(index){
            layerFn.closeIndex(index);
          }
          if(search){
            thisPage.search();
          }
          if(data){
            layerFn.handleResult(data.msg,data.code);
          }
        }catch(e){}
      }
    };
    thisPage.init();
    $('script').remove();
  })(jQuery);
</script>